import React, { Component } from 'react'
import { Route } from 'react-router-dom'
// import routerList from './routerConfig'

export default class RouterView extends Component {
    render() {
        const { routes } = this.props
        return (
            <div className="h100">
               {/* {
                   routerList.map((item, index) => {
                       return <Route path = { item.path } component = { item.com } key = { index }/>
                   })
               } */}

                {
                   routes.map((item, index) => {
                       return <Route path = { item.path } render = {(prop) => {
                           //    prop  路由信息
                           let Com = item.com
                           //  如果当前路由下有children才传递
                           if (item.children) {
                               return <Com children = { item.children }/>
                           } else {
                               return <Com/>
                           } 
                           
                       }} key = { index }/>
                   })
                }


               {/* 第一次使用 */}
               {/* <Route path = "/home" component = { Home }/>
               <Route path = "/detail"/> */}

                {/* 第二次使用 */}
                {/* <Route path = "/home/homes" component = {Homes} />
                <Route path = "/home/referrer" component = {referrer} />
                <Route path = "/home/app" component = {App} />
                <Route path = "/home/my" component = {My} /> */}
            </div>
        )
    }
}
